import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState   from 'vuex-persistedstate' //解决Vuex持久化插件-在F5刷新页面后数据不见的问题

Vue.use(Vuex)

const store = new Vuex.Store({
	state:{
		//用户名
		username        : '',
		//token
		token           : null,
		//面包屑
		breadcrumbItems : [],
		//登录modal框 显示 隐藏
		login_visible   : false,
		 
	},
	getters:{
		username        : state => state.username, 
		token           : state => state.token, 
		breadcrumbItems : state => state.breadcrumbItems, 
		login_visible   : state => state.login_visible, 
	},
	mutations : {
		//用户名
		setusername(state,data){
			state.username = data
		}, 
		settoken(state,data){
			state.token = data
		},
		setbreadcrumbItems(state,data){
			state.breadcrumbItems = data
		},  
		setlogin_visible(state,data){
			state.login_visible = data
		}, 
	},
	actions:{

	},
	plugins: [createPersistedState({
		//默认存储到localStorage
		//想要存储到sessionStorage，配置如下
		storage: window.sessionStorage
	})]
})

export default store